using System;
using System.ComponentModel.Composition;
using System.Windows.Forms;
using ICP_MS.Plugin.Advance.Properties;

namespace ICP_MS.Plugin.Advance;

public class AdvancePlugin : Extension
{
	private FormAdvance form = null;

	private SimpleActionItem button;

	[Import("Shell", typeof(ContainerControl))]
	private ContainerControl Shell { get; set; }

	public override int Priority => -2000;

	public override void Activate()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		button = new SimpleActionItem(Lang.Txt("iMass.Menu.Advance.Text"), (EventHandler)Button_Click)
		{
			Direction = (Direction)1,
			LargeImage = Resources.Advance,
			SmallImage = Resources.Advance,
			ToggleGroupKey = "kLeftBar",
			GroupCaption = "Advance",
			Size = 80
		};
		((Extension)this).App.HeaderControl.Add((HeaderItem)(object)button);
		Shell = ((Extension)this).App.Shell;
		((Extension)this).Activate();
	}

	public override void Deactivate()
	{
		((Extension)this).Deactivate();
	}

	private void Button_Click(object sender, EventArgs e)
	{
		if (form == null)
		{
			form = new FormAdvance();
			form.FormClosed += delegate
			{
				form.Dispose();
				form = null;
			};
			form.Activated += delegate
			{
				button.Toggle();
			};
			form.MdiParent = Shell as Form;
			form.Show();
		}
		else
		{
			form.Activate();
			form.BringToFront();
		}
	}
}
